﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using Agnes.Core;
using Caliburn.Micro;

namespace Agnes.TaskManager
{
    class TaskLabelsEditorCmd
    {
        private static TaskLabelsEditorCmd _instance;

        /// <summary>
        /// 返回唯一实例
        /// </summary>
        public static TaskLabelsEditorCmd Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new TaskLabelsEditorCmd();
                }
                return _instance;
            }
        }

        private RoutedCommand _requery;

        /// <summary>
        /// 是否能执行
        /// </summary>
        public bool CanExcuted { get; set; }

        TaskLabelsEditorCmd()
        {
            CanExcuted = false;
            _requery = new RoutedCommand("Task Labels Editor Cmd", typeof(TaskLabelsEditorCmd));
        }

        /// <summary>
        /// 浏览文章的路由命令
        /// </summary>
        public static RoutedCommand Requery
        {
            get
            {
                return Instance._requery;
            }
        }

        /// <summary>
        /// 浏览文章执行代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void Excuted(object sender, ExecutedRoutedEventArgs e)
        {
            IWindowManager windowManager = IoC.Get<IWindowManager>();
            windowManager.ShowDialog(new TaskLabelEditViewModel());
            TaskManagerService.TaskManager.SaveLabels();
        }

        /// <summary>
        /// 判断是否能执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CanExcute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
    }
}
